﻿using UnityEditor;
using UnityEngine;

public class ArtEditor : Editor {

    /// <summary>
    /// 运行状态中保存预制体
    /// </summary>
    [MenuItem("GameObject/SavePrefab")]
    static public void SavePrefab()
    {
        GameObject source = PrefabUtility.GetPrefabParent(Selection.activeGameObject) as GameObject;
        if (source == null) return;
        string prefabPath = AssetDatabase.GetAssetPath(source).ToLower();
        if (prefabPath.EndsWith(".prefab") == false) return;
        PrefabUtility.ReplacePrefab(Selection.activeGameObject, source, ReplacePrefabOptions.ConnectToPrefab | ReplacePrefabOptions.ReplaceNameBased);
    }

}
